package myDbInit;

import java.sql.*;

public class dbInit {
    private Connection con;
    private PreparedStatement ps;
    private ResultSet rs;


    public PreparedStatement getPs(){
        return ps;
    }

    public ResultSet getRs(){
        return rs;
    }

    public Connection getCon(){
        return this.con;
    }
 public    dbInit(){

        try {
            DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
            con=DriverManager.getConnection("jdbc:mysql://localhost:3306/db_Lunwen?serverTimezone=CST&userUnicode=true&characterEncoding=utf-8","root","root");

        }catch (SQLException e){
           e.printStackTrace();
        }
    }

 public  void close(){
     try {
         if(rs!=null){
             rs.close();
         }

         if(ps!=null){
             ps.close();
         }

         if(con!=null){
             con.close();
         }
     }catch (SQLException e){e.printStackTrace();}

 }
}
